# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=csview
pkgver=1.1.0
pkgrel=0
pkgdesc="Pretty csv viewer for cli with cjk/emoji support"
url="https://github.com/wfxr/csview"
arch="aarch64 armhf armv7 ppc64le x86 x86_64"  # blocked by rust/cargo
license="Apache-2.0 OR MIT"
makedepends="cargo"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/wfxr/csview/archive/v$pkgver/csview-$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	install -D -m644 completions/bash/$pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname

	install -D -m644 completions/fish/* -t "$pkgdir"/usr/share/fish/completions/
	install -D -m644 completions/zsh/* -t "$pkgdir"/usr/share/zsh/site-functions/
}

sha512sums="
670920c3f1c8ca64fb61a7b9e7c7bc0726647236445773994da930b92840be166ab7929177332374348094ab3d90193f2fa9f1b6de6c91228e350f46c1751457  csview-1.1.0.tar.gz
"
